package de.tum.in.eist.poll.client;

import java.util.List;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

import de.tum.in.eist.poll.shared.Feedback;
import de.tum.in.eist.poll.shared.Lecture;
import de.tum.in.eist.poll.shared.User;

/**
 * The client side stub for the RPC service.
 */
@RemoteServiceRelativePath("pollService")
public interface PollService extends RemoteService {
	/**
	 * Requests a login by sending name and password.
	 * 
	 * @param name
	 *            the name sent by the client
	 * @param password
	 *            the password sent by the client
	 * @return the user corresponding to name and password
	 * @throws IllegalArgumentException
	 *             if name and password don't match
	 */
	User login(String name, String password) throws IllegalArgumentException;

	/**
	 * Requests a list of all lectures relevant to this user.
	 * 
	 * @param user
	 *            the user that requested this list
	 * @return a list of all lectures relevant to the user
	 */
	List<Lecture> requestLectures(User user);

	/**
	 * Requests all feedback for a lecture.
	 * 
	 * @param lecture
	 *            the lecture to get feedback for
	 * @return all of the feedback corresponding to a lecture
	 */
	List<Feedback> requestFeedback(Lecture lecture);

	/**
	 * Submit feedback to the server.
	 * 
	 * @param feedback
	 *            the feedback to submit.
	 * @return the server's answer
	 */
	String submitFeedback(Feedback feedback);
	
	
	/**
	 * Returns the number of feedbacks submitted for a specific lecture.
	 * This method makes polling for new feedback from the feedback screen more efficient,
	 * since we don't need to request the full list of feedback via requestFeedback() to check for changes anymore.
	 * @param lecture
	 * @return feedback count
	 */
	int requestFeedbackCount(Lecture lecture);

}
